<?php
    $event = $this->event;
    $eventID = $this->id;
?>
    <div class="row">
        &nbsp;
    </div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">Event</h3>
				</div>

				<div class="panel-body">
				
				    <div class="form-group">
						<div class="col-md-2 control-label">Event Title:</div>
						<div class="col-md-10">
                            <?php echo $event->TITLE; ?>
                        </div>
					</div>
					
					<div class="form-group">
						<div class="col-md-2 control-label">Date:</div>
						<div class="col-md-10">
                            <?php  echo $event->DATE; ?>
                        </div>
					</div>
					
					<div class="form-group">
						<div class="col-md-2 control-label">Category</div>
						<div class="col-md-10">
						    <?php 
				                    $category="";
            			            if($this->escapeHtml($event->CATEGORY)==1){
            			                $category="Main";
            			            }
            			            else if($this->escapeHtml($event->CATEGORY)==2){
            			                $category="District";
            			            }
            			            else if($this->escapeHtml($event->CATEGORY)==3){
            			                $category="Regional";
            			            }
        			        ?>
                            <?php  echo $category; ?>
                        </div>
					</div>
					
					<div class="form-group">
						<div class="col-md-2 control-label">Subject:</div>
						<div class="col-md-10">
                            <?php  echo $event->SUBJECT; ?>
                        </div>
					</div>
					
					<div class="form-group">
						<div class="col-md-2 control-label">Place:</div>
						<div class="col-md-10">
                            <?php  echo $event->PLACE; ?>
                        </div>
					</div>
					
					<div class="form-group">
						<div class="col-md-2 control-label">Status:</div>
						<div class="col-md-10">
						    <?php 
				                    $category="";
            			            if($this->escapeHtml($event->EVENT_STATUS)==1){
            			                $status="Pending";
            			            }
            			            else if($this->escapeHtml($event->EVENT_STATUS)==2){
            			                $status="Completed";
            			            }
        			        ?>
                            <?php  echo $status; ?>
                        </div>
					</div>				
					
				</div>
			</div>
		</div>
		
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">Add Session or Additional Resource</h3>					
				</div>
                <a href="#identifier" class="btn btn-default" id="add_session"><span class="glyphicon glyphicon-plus text-primary" aria-hidden="true">Session</span></a>
                <a href="#identifier" class="btn btn-default" id="add_resource"><span class="glyphicon glyphicon-plus text-primary" aria-hidden="true">Resource</span></a>                          	    
                <a id="identifier"> &nbsp;</a>				
				<div class="panel-body">
				
				<?php 		
                    $add_sessionform = $this->add_sessionform;
                    $session_list=$this->session_list;
                        
                    $add_sessionform->setAttribute ( 'action', $this->url ( NULL, array (
                    		/* 'controller' => 'Index',
                    		'action' => 'process',
                    		'id' => $this->id  */
                    ) ) );
                    $add_sessionform->prepare ();
                    
                    $value = 0;
                    $option = array ();
                    foreach ( $session_list as $session ) {
                        $value = $this->escapeHtml ( $session->TOPIC ); // 'name' name of the column in the database
                        $id = $this->escapeHtml ( $session->ID );
                        $option [] = array (
                            'value' => $id,
                            'label' => $value
                        );
                    }
                    $add_sessionform->get ( 'SESSIONS' )->setAttributes ( array (
                        'options' => $option
                    ) );
                ?>
				
				<div class="col-md-7">
    				<div class="panel panel-default" id="add_sessionpanel">
    				<div class="panel-heading">
    					<h3 class="panel-title">Add Session</h3>					
    				</div>
    
    				<div class="panel-body">				
        				<?php echo $this->form()->openTag($add_sessionform); ?>
        				<?php
            				echo $this->formelement ( $add_sessionform->get ( 'ID' ) );
        				?>
                            <div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_sessionform->get('SESSIONS'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_sessionform->get('SESSIONS'));?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_sessionform->get('SESSIONS')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_sessionform->get('DURATION'));?></label>
        						<div class="col-md-8">
        							<div class="col-md-4" style="padding:0px">
                                    	<?php   echo $this->formElement($add_sessionform->get('DURATION')); ?>
                                    </div>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_sessionform->get('DURATION')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_sessionform->get('DATE'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_sessionform->get('DATE')); ?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_sessionform->get('DATE')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_sessionform->get('STARTING_TIME'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_sessionform->get('STARTING_TIME')); ?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_sessionform->get('STARTING_TIME')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"></label>
        						<div class="col-md-8">
                                    <?php echo $this->formElement($add_sessionform->get('BTNADD')); ?>
                                    <?php echo $this->formElement($add_sessionform->get('BTNCLOSE')); ?>
        						</div>
        					</div>                  
                            
                        <?php echo $this->form()->closeTag();?>
                      </div>
                      </div>
                </div>
                
                <?php 		
                    $add_resourceform = $this->add_resourceform;
                    $resource_list=$this->resource_list;
                        
                    $add_resourceform->setAttribute ( 'action', $this->url ( NULL, array (
                    		/* 'controller' => 'Index',
                    		'action' => 'process',
                    		'id' => $this->id  */
                    ) ) );
                    $add_resourceform->prepare ();
                    
                    $value = 0;
                    $option = array ();
                    foreach ( $resource_list as $resource ) {
                        $value = $this->escapeHtml ( $resource->TITLE ); // 'name' name of the column in the database
                        $id = $this->escapeHtml ( $resource->ID );
                        $option [] = array (
                            'value' => $id,
                            'label' => $value
                        );
                    }
                    $add_resourceform->get ( 'RESOURCE' )->setAttributes ( array (
                        'options' => $option
                    ) );
                    
                ?>
                   
                <div class="col-md-7">
    				<div class="panel panel-default" id="add_resourcepanel">
    				<div class="panel-heading">
    					<h3 class="panel-title">Add Resource</h3>					
    				</div>
    
    				<div class="panel-body">				
        				<?php echo $this->form()->openTag($add_resourceform); ?>
        				<?php
            				echo $this->formelement ( $add_resourceform->get ( 'ID' ) );
        				?>
                            <div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_resourceform->get('RESOURCE'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_resourceform->get('RESOURCE'));?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_resourceform->get('RESOURCE')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_resourceform->get('DURATION'));?></label>
        						<div class="col-md-8">
        							<div class="col-md-4" style="padding:0px">
                                    	<?php   echo $this->formElement($add_resourceform->get('DURATION')); ?>
                                    </div>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_resourceform->get('DURATION')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_resourceform->get('DATE'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_resourceform->get('DATE')); ?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_resourceform->get('DATE')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"><?php echo $this->formlabel($add_resourceform->get('STARTING_TIME'));?></label>
        						<div class="col-md-8">
                                    <?php   echo $this->formElement($add_resourceform->get('STARTING_TIME')); ?>
                                    <span class="errormsgform"><?php   echo $this->formElementErrors($add_resourceform->get('STARTING_TIME')); ?></span>
        						</div>
        					</div>
        
        					<div class="form-group">
        						<label class="col-md-4 control-label"></label>
        						<div class="col-md-8">
                                    <?php echo $this->formElement($add_resourceform->get('BTNADD')); ?>
                                    <?php echo $this->formElement($add_resourceform->get('BTNCLOSE')); ?>
        						</div>
        					</div>                  
                            
                        <?php echo $this->form()->closeTag();?>
                      </div>
                      </div>
                </div>
                   
				</div>
			</div>
		</div>
				
	</div>
	
	
<script type="text/javascript">

    $(document).ready(function() {
        guiInit();

        $("#add_sessionbtn").click(function() {
            $("#add_sessionform").submit(function(){
            	var postData = $(this).serializeArray();
        		$.ajax(
     				   {
                			method: "POST",
                			url: "<?php echo $this->url('events', array('controller'=>'Index','action'=>'validatesessionform')); ?>",
        	    	        data : postData,
        	    	        success:function(data, textStatus, jqXHR) 
        	    	        {
        	    	            //data: return data from server
        	    	        },
        	    	        error: function(jqXHR, textStatus, errorThrown) 
        	    	        {
        	    	            //if fails      
        	    	        }
          			   });
        	     });
        });
    });

    
 	   
		    
    
    guiInit=function(){       

        
     	 $("#add_session").click(
	        function() {
	            	if($('#add_resourcepanel').is(':visible')){
	                	$("#add_resourcepanel").hide();  
	            		$("#add_sessionpanel").show();     
	                }
	            	else{
	            		$("#add_sessionpanel").show();
	            	}                
	            }
	        );

	        $("#add_sessionformclosebtn").click(
	             function() {
	                $("#add_sessionpanel").hide();
	            }
	        );

	        $("#add_resource").click(
	             function() {
	            	 if($('#add_sessionpanel').is(':visible')){
	                  	$("#add_sessionpanel").hide();  
	              		$("#add_resourcepanel").show();    
	                  }
	              	else{
	              		$("#add_resourcepanel").show();
	              	}
	            }
	        );

	        $("#add_resourceformclosebtn").click(
	             function() {
	                $("#add_resourcepanel").hide();
	            }
	        );        

	        $( document ).ready(function() {
	    		$("#add_sessionpanel").hide();
	    		$("#add_resourcepanel").hide();
	    	});
      };//end of guiInit
</script>
